package cn.boyu.service.impl;

import cn.boyu.entity.SysRole;
import cn.boyu.mapper.SysRoleMapper;
import cn.boyu.query.RoleQuery;
import cn.boyu.service.ISysRoleService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author yn
 * @since 2022-11-22
 */
@Service
public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> implements ISysRoleService {

    @Override
    public IPage<SysRole> queryPage(RoleQuery qo) {
        IPage<SysRole> page =new Page<>(qo.getCurrentPage(),qo.getPageSize());
        QueryWrapper<SysRole> qw =new QueryWrapper<>();
        qw.like(qo.getRoleName()!=null && qo.getRoleName()!="","role_name",qo.getRoleName()).or().like(qo.getRoleName()!=null && qo.getRoleName()!="","role_key",qo.getRoleName());
//        qw.like();

//        qw.like("role_name",qo.getRoleId());
        return this.page(page,qw);
    }
}
